'use strict';

import { VENDOR_LOGO } from '../const/vendor-logo';

/**
 * 设置样式
 * @param {element} elem DOM元素
 * @param {object|string} name CSS样式对象
 * @param {string} val CSS样式对象
 */
export function setStyle(elem, name, val) {
    if (name) {
        const isObj = Object.prototype.toString.call(name) === "[object Object]";
        const elStyle = elem.style;
        if (isObj) {
            for (const key in name) {
                const compat = /^transition|animation|transform/.test(key)
                    ? VENDOR_LOGO + key.charAt(0).toUpperCase() + key.substr(1)
                    : key;
                elStyle[compat] = name[key];
            }
        } else {
            elStyle[name] = val;
        }
    }
};